<!DOCTYPE html>
<html>
<head>
    <title>修改住院信息--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../layer/layer.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<form action="#" id="myForm" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">病历号</td>
        <td id="hosR_id">1101</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td id="hosR_name">黄飞鸿</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">证件号</td>
        <td id="hosR_idCar">42068325467876</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">社保号</td>
        <td id="hosR_medical">423423432</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">联系电话</td>
        <td id="hosR_phone">13126576456</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">是否自费</td>
        <td id="hosR_selfPrice"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td id="hosR_sex"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td id="hosR_age">33</td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">初复诊</td>
        <td id="hosR_lookDoctor"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">指定医生</td>
        <td id="d_name"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">备注</td>
        <td id="hosR_remark"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">护理人</td>
        <td><input type="text" name="beH_nursePeople" id="beH_nursePeople" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">床位号</td>
        <td><input type="text" name="beH_patBed" id="beH_patBed" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">缴费押金</td>
        <td><input type="text" name="beH_antecedent" id="beH_antecedent" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">病情</td>
        <td><textarea name="beH_illness" id="beH_illness"></textarea></td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
				<button type="button" class="btn btn-primary" onclick="upload()">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backId">返回列表</button>
			</center>
		</td>
    </tr>
</table>
    <input type="hidden" id="beH_id" name="beH_id" value="">
</form>
</body>
</html>
<script type="text/javascript">
    String.prototype.GetValue= function(para) {
        let reg = new RegExp("(^|&)"+ para +"=([^&]*)(&|$)");
        let r = this.substr(this.indexOf("\?")+1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
    }
    $(function () {
        //根据地址获取teamId,如果null则执行增加，否则执行更新
        let url = document.location.toString();//获取URL
        let beH_id = url.GetValue("beH_id");
        let pageNum = url.GetValue("pageNum");
        $("#beH_id").val(beH_id);
        load(beH_id);
        $('#backId').click(function(){
            window.location.href="index.html?pageNum="+pageNum;
        });
    });

    function load(beH_id){
        let windowId = layer.load();
        $.ajax({
            type: "GET",
            url: "/hospital/queryById/"+beH_id, //RESTful风格的API定义
            data: "",
            dataType:"json",
            success: function (vo) {
                layer.close(windowId);
                if (vo.code == 200){
                    let obj=vo.obj;
                    let beH_nursePeople=obj.beH_nursePeople;
                    let beH_patBed=obj.beH_patBed;
                    let beH_antecedent=obj.beH_antecedent;
                    let beH_illness=obj.beH_illness;
                    let hosR_name=obj.hosregister.hosR_name==null?'数据丢失':obj.hosregister.hosR_name;
                    let hosR_idCar=obj.hosregister.hosR_idCar==null?'数据丢失':obj.hosregister.hosR_idCar;
                    let hosR_regPrice=obj.hosregister.hosR_regPrice;
                    let hosR_medical=obj.hosregister.hosR_medical==null?'数据丢失':obj.hosregister.hosR_medical;
                    let hosR_phone=obj.hosregister.hosR_phone==null?'数据丢失':obj.hosregister.hosR_phone;
                    let hosR_selfPrice=obj.hosregister.hosR_selfPrice=='0'?'自费':'免费';
                    let hosR_sex=obj.hosregister.hosR_sex=='0'?'女':'男';
                    let hosR_age=obj.hosregister.hosR_age;
                    let hosR_work=obj.hosregister.hosR_work==null?'数据丢失':obj.hosregister.hosR_work;
                    let hosR_lookDoctor=obj.hosregister.hosR_lookDoctor=='0'?'初诊':'复诊';
                    let d_name=obj.hosregister.doctor.d_name==null?'':obj.hosregister.doctor.d_name;
                    let hosR_remark=obj.hosregister.hosR_remark==null?'数据丢失':obj.hosregister.hosR_remark;
                    $("#hosR_name").html(hosR_name);
                    $("#hosR_idCar").html(hosR_idCar);
                    $("#hosR_regPrice").html(hosR_regPrice);
                    $("#hosR_medical").html(hosR_medical);
                    $("#hosR_phone").html(hosR_phone);
                    $("#hosR_selfPrice").html(hosR_selfPrice);
                    $("#hosR_sex").html(hosR_sex);
                    $("#hosR_age").html(hosR_age);
                    $("#hosR_work").html(hosR_work);
                    $("#hosR_lookDoctor").html(hosR_lookDoctor);
                    $("#d_name").html(d_name);
                    $("#hosR_remark").html(hosR_remark);
                    $("#beH_nursePeople").val(beH_nursePeople);
                    $("#beH_patBed").val(beH_patBed);
                    $("#beH_antecedent").val(beH_antecedent);
                    $("#beH_illness").val(beH_illness);
                }else {
                    layer.msg(vo.msg);
                }
            }
        });
    }

    function upload(){
        let windowId = layer.load();
        $.ajax({
            type: "POST",
            url: "/hospital/update",
            data: $("#myForm").serialize()+"&_method=PUT",
            dataType: "json",
            success: function (vo) {
                layer.close(windowId);
                alert(vo.msg);
                if (vo.code == 200){
                    window.location.href="index.html";
                }
            }
        });
    }
</script>